home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
4_4.lha
/
4_4
/
4_4.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
824b
|
53 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ concatenate the listed files
/ onto the standard output
include <stream.h>
/ Copy a given file to cout.
/ Return 1 if there is an error.
nt cat(char *file)
filebuf f1;
if (f1.open(file, input) == 0)
{
cerr << "cannot open input file '" <<
file << "'\n";
return 1;
}
istream from(&f1);
char ch;
while (from.get(ch) && cout.put(ch))
;
if (cout.bad())
{
cerr << "error on writing output\n";
return 1;
}
else if (!from.eof())
{
cerr << "error on reading input file '" <<
file << "'\n";
return 1;
}
return 0;
nt main(int argc, char **argv)
int err = 0;
// loop through files
while (--argc > 0)
err += cat(*++argv);
return err;